#ifndef IAP2DEF_H_
#define IAP2DEF_H_

#include <map>
#include "CIpodLib.h"

/**************************************************************************************
 * Section: Miscellaneous iAP2 Constants
 **************************************************************************************/

#define IAP2_TOTAL_MAX_OUTSTANDING_PACKETS                          1       // Valid values: 1 - 127 for each transport

#define IAP2_MIN_CONTROL_SESSION_PAYLOAD_LENGTH                     ( 1024 + 10 + 6 )
#if IAP2_MAXIMUM_PACKET_LENGTH_OUT < IAP2_MINIMUM_PACKET_LENGTH
#error Output packet length too small
#endif

#define IAP2_MINIMUM_PACKET_LENGTH                                  ( 10 + 6 + 1024 )
#define IAP2_MAXIMUM_PAYLOAD_LENGTH                                 65525
#define IAP2_MAXIMUM_PACKET_LENGTH_IN                               65535
#define IAP2_MAXIMUM_PACKET_LENGTH_OUT                              65535

#define IAP2_LINK_SOM_MSB                                           0xFF    // Value for the MSB of Start of Link
#define IAP2_LINK_SOM_LSB                                           0x5A    // Value for the LSB of Start of Link
#define IAP2_CONTROL_SESSION_SOM_MSB                                0x40    // Value for the MSB of Start of Message
#define IAP2_CONTROL_SESSION_SOM_LSB                                0x40    // Value for the LSB of Start of Message
#define IAP2_CONTROL_SESSION_HEADER_LENGTH                          6       // Number of bytes in a control session message header
#define IAP2_MESSAGE_PARAMETER_HEADER_LENGTH                        4       // Number of bytes in a message parameter header
#define IAP2_MESSAGE_SUB_PARAMETER_HEADER_LENGTH                    4       // Number of bytes in a message sub-parameter header
#define IAP2_LINK_HEADER_LENGTH                                     9       // Number of bytes in a link header
#define IAP2_FILE_PAYLOAD_HEADER_LENGTH                             2       // Number of bytes in File Transfer payload header
#define IAP2_EA_PAYLOAD_HEADER_LENGTH                               2       // Number of bytes in EA Transfer payload header

#define IAP2_LINK_VERSION                                           0x01
#define IAP2_MAXIMUM_NUMBER_OF_OUTSTANDING_PACKETS                  5       // 最大未确认数据包数量：设置在未收到确认之前可以发送的最大数据包数量，这里设置为 5 个数据包，最大数量：这个参数限制了发送方在没有收到确认之前，最多可以发送多少个这样的未确认数据包,约束对端的。
#define IAP2_MAXIMUM_RECEIVED_PACKET_LENGTH                         4096    // 定义设备能够接收的单个数据包的最大长度。在这里，最大长度为 4096 字节。
#define IAP2_RETRANSMISSION_TIMEOUT                                 1035    // 重传超时 控制的是发送方在没有收到确认时，何时重发数据包。
#define IAP2_CUMULATIVE_ACKNOWLEDGEMENT_TIMEOUT                     200     // 累积确认超时 控制的是接收方什么时候发送确认消息。
#define IAP2_MAXIMUM_NUMBER_OF_RETRANSMISSIONS                      3       // 控制了发送方的行为，即如果确认没有及时收到，最多尝试 3 次重发数据包，保障了数据传输的可靠性。
#define IAP2_MAXIMUM_CUMULATIVE_ACKNOWLEDGEMENTS                    3       // 最大累积确认次数,控制了接收方的行为，即可以最多累积 3 个包的确认，从而优化了通信效率，减少确认消息的频繁发送。

#define IAP2_SESSION_TYPE_CONTROL                                   0
#define IAP2_SESSION_TYPE_FILE_TRANSFER                             1
#define IAP2_SESSION_TYPE_EA                                        2

#define IAP2_SESSION_ID_ACK                                         0x00
#define IAP2_SESSION_ID_ACK_BYD                                     0x0A
#define IAP2_SESSION_ID_CONTROL                                     0x0A
#define IAP2_SESSION_ID_FILE_TRANSFER                               0x0B
#define IAP2_SESSION_ID_EA                                          0x0C

#define IAP2_SESSION_VERSION_CONTROL_NORMAL                         0x01
#define IAP2_SESSION_VERSION_CONTROL_CARPLAY                        0x02
#define IAP2_SESSION_VERSION_FILE_TRANSFER                          0x01
#define IAP2_SESSION_VERSION_EA                                     0x01

#define LIBRARY_REVISION                                            "library_revision"

//#define IAP2_SERIAL_NUMBER_BY_BTADDRESS

/**************************************************************************************
 * Section: IAP2 Protocol Message Constant
 **************************************************************************************/

//**************************************************************************************
// IAP2 message, Accessory Authentication

#define IAP2_ACCESSORY_AUTHENTICATION                                                       0xAA

#define IAP2_AA_RequestAuthenticationCertificate                                            0x00
#define IAP2_AA_AuthenticationCertificate                                                   0x01
#define IAP2_AA_RequestAuthenticationChallengeResponse                                      0x02
#define IAP2_AA_AuthenticationResponse                                                      0x03
#define IAP2_AA_AuthenticationFailed                                                        0x04
#define IAP2_AA_AuthenticationSucceeded                                                     0x05
#define IAP2_AA_AccessoryAuthenticationSerialNumber                                         0x06

//**************************************************************************************
// IAP2 message, Accessory Authentication, RequestAuthenticationCertificate

#define IAP2_AA_RAC_RequestAuthenticationCertificateSerialNumber                            0

//**************************************************************************************
// IAP2 message, Accessory Authentication, AuthenticationCertificate

#define IAP2_AA_AC_AuthenticationCertificate                                                0

//**************************************************************************************
// IAP2 message, Accessory Authentication, RequestAuthenticationChallengeResponse

#define IAP2_AA_RACR_AuthenticationChallenge                                                0

//**************************************************************************************
// IAP2 message, Accessory Authentication, AccessoryAuthenticationSerialNumber

#define IAP2_AA_AASN_AuthenticationSerialNumber                                             0

//**************************************************************************************
// IAP2 message, Accessory Identification

#define IAP2_ACCESSORY_IDENTIFICATION                                                       0x1D

#define IAP2_AI_StartIdentification                                                         0x00
#define IAP2_AI_IdentificationInformation                                                   0x01
#define IAP2_AI_IdentificationAccepted                                                      0x02
#define IAP2_AI_IdentificationRejected                                                      0x03
#define IAP2_AI_CancelIdentification                                                        0x05
#define IAP2_AI_IdentificationInformationUpdate                                             0x06

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation

#define IAP2_AI_II_Name                                                                     0
#define IAP2_AI_II_ModelIdentifier                                                          1
#define IAP2_AI_II_Manufacturer                                                             2
#define IAP2_AI_II_SerialNumber                                                             3
#define IAP2_AI_II_FirmwareVersion                                                          4
#define IAP2_AI_II_HardwareVersion                                                          5
#define IAP2_AI_II_MessagesSentByAccessory                                                  6
#define IAP2_AI_II_MessagesReceivedFromDevice                                               7
#define IAP2_AI_II_PowerProvidingCapability                                                 8
#define IAP2_AI_II_MaximumCurrentDrawnFromDevice                                            9
#define IAP2_AI_II_SupportedExternalAccessoryProtocol                                       10
#define IAP2_AI_II_AppMatchTeamID                                                           11
#define IAP2_AI_II_CurrentLanguage                                                          12
#define IAP2_AI_II_SupportedLanguage                                                        13
#define IAP2_AI_II_SerialTransportComponent                                                 14
#define IAP2_AI_II_USBDeviceTransportComponent                                              15
#define IAP2_AI_II_USBHostTransportComponent                                                16
#define IAP2_AI_II_BluetoothTransportComponent                                              17
#define IAP2_AI_II_iAP2HIDComponent                                                         18
#define IAP2_AI_II_VehicleInformationComponent                                              20
#define IAP2_AI_II_VehicleStatusComponent                                                   21
#define IAP2_AI_II_LocationInformationComponent                                             22
#define IAP2_AI_II_USBHostHIDComponent                                                      23
#define IAP2_AI_II_WirelessCarPlayTransportComponent                                        24
#define IAP2_AI_II_BluetoothHIDComponent                                                    29
#define IAP2_AI_II_RouteGuidanceDisplayComponent                                            30
#define IAP2_AI_II_ProductPlanUID                                                           34

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, ExternalAccessoryProtocol

#define IAP2_AI_II_EAP_ExternalAccessoryProtocolIdentifier                                  0
#define IAP2_AI_II_EAP_ExternalAccessoryProtocolName                                        1
#define IAP2_AI_II_EAP_ExternalAccessoryProtocolMatchAction                                 2
#define IAP2_AI_II_EAP_NativeTransportComponentIdentifier                                   3
#define IAP2_AI_II_EAP_ExternalAccessoryProtocolCarPlay                                     4

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, USBDeviceTransportComponent

#define IAP2_AI_II_USBDTC_TransportComponentIdentifier                                      0
#define IAP2_AI_II_USBDTC_TransportComponentName                                            1
#define IAP2_AI_II_USBDTC_TransportSupportsiAP2Connection                                   2
#define IAP2_AI_II_USBDTC_USBDeviceSupportedAudioSampleRate                                 3

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, USBHostTransportComponent

#define IAP2_AI_II_USBHTC_TransportComponentIdentifier                                      0
#define IAP2_AI_II_USBHTC_TransportComponentName                                            1
#define IAP2_AI_II_USBHTC_TransportSupportsiAP2Connection                                   2
#define IAP2_AI_II_USBHTC_USBHostTransportCarPlayInterfaceNumber                            3
#define IAP2_AI_II_USBHTC_TransportSupportsCarPlay                                          4

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, SerialTransportComponent

#define IAP2_AI_II_STC_TransportComponentIdentifier                                         0
#define IAP2_AI_II_STC_TransportComponentName                                               1
#define IAP2_AI_II_STC_TransportSupportsiAP2Connection                                      2

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, BluetoothTransportComponent

#define IAP2_AI_II_BTC_TransportComponentIdentifier                                         0
#define IAP2_AI_II_BTC_TransportComponentName                                               1
#define IAP2_AI_II_BTC_TransportSupportsiAP2Connection                                      2
#define IAP2_AI_II_BTC_BluetoothTransportMediaAccessControlAddress                          3

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, iAP2HIDComponent

#define IAP2_AI_II_HIDC_HIDComponentIdentifier                                              0
#define IAP2_AI_II_HIDC_HIDComponentName                                                    1
#define IAP2_AI_II_HIDC_HIDComponentFunction                                                2

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, VehicleInformationComponent

#define IAP2_AI_II_VIC_Identifier                                                           0
#define IAP2_AI_II_VIC_Name                                                                 1
#define IAP2_AI_II_VIC_EngineType                                                           2
#define IAP2_AI_II_VIC_DisplayName                                                          6

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, VehicleStatusComponent

#define IAP2_AI_II_VSC_Identifier                                                           0
#define IAP2_AI_II_VSC_Name                                                                 1
#define IAP2_AI_II_VSC_Range                                                                3
#define IAP2_AI_II_VSC_OutsideTemperature                                                   4
#define IAP2_AI_II_VSC_RangeWarning                                                         6

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, LocationInformationComponent

#define IAP2_AI_II_LIC_Identifier                                                           0
#define IAP2_AI_II_LIC_Name                                                                 1
#define IAP2_AI_II_LIC_GlobalPositioningSystemFixData                                       17
#define IAP2_AI_II_LIC_RecommendedMinimumSpecificGPSTransitData                             18
#define IAP2_AI_II_LIC_GPSSatellitesInView                                                  19
#define IAP2_AI_II_LIC_VehicleSpeedData                                                     20
#define IAP2_AI_II_LIC_VehicleGyroData                                                      21
#define IAP2_AI_II_LIC_VehicleAccelerometerData                                             22
#define IAP2_AI_II_LIC_VehicleHeadingData                                                   23

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, USBHostHIDComponent

#define IAP2_AI_II_USBHHIDC_HIDComponentIdentifier                                          0
#define IAP2_AI_II_USBHHIDC_HIDComponentName                                                1
#define IAP2_AI_II_USBHHIDC_HIDComponentFunction                                            2
#define IAP2_AI_II_USBHHIDC_USBHostTransportComponentIdentifier                             3
#define IAP2_AI_II_USBHHIDC_USBHostTransportInterfaceNumber                                 4

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, WirelessCarPlayTransportComponent

#define IAP2_AI_II_WCTC_TransportComponentIdentifier                                        0
#define IAP2_AI_II_WCTC_TransportComponentName                                              1
#define IAP2_AI_II_WCTC_TransportSupportsiAP2Connection                                     2
#define IAP2_AI_II_WCTC_TransportSupportsCarPlay                                            4

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, BluetoothHIDComponent

#define IAP2_AI_II_BHIDC_HIDComponentIdentifier                                             0
#define IAP2_AI_II_BHIDC_HIDComponentName                                                   1
#define IAP2_AI_II_BHIDC_HIDComponentFunction                                               2
#define IAP2_AI_II_BHIDC_BluetoothTransportComponentIdentifier                              3

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformation, RouteGuidanceDisplayComponent
#define IAP2_AI_II_RGDC_Identifier                                  0    // See the Accessory Interface Specification for more information.
#define IAP2_AI_II_RGDC_Name                                        1    // See the Accessory Interface Specification for more information.
#define IAP2_AI_II_RGDC_MaxCurrentRoadNameLength                    2    // See the Accessory Interface Specification for more information.
#define IAP2_AI_II_RGDC_MaxDestinationNameLength                    3    // See the Accessory Interface Specification for more information.
#define IAP2_AI_II_RGDC_MaxAfterManeuverRoadNameLength              4    // See the Accessory Interface Specification for more information.
#define IAP2_AI_II_RGDC_MaxManeuverDescriptionLength                5    // See the Accessory Interface Specification for more information.
#define IAP2_AI_II_RGDC_MaxGuidanceManeuverStorageCapacity          6    // See the Accessory Interface Specification for more information.
#define IAP2_AI_II_RGDC_MaxLaneGuidanceDescriptionLength            7    // See the Accessory Interface Specification for more information.
#define IAP2_AI_II_RGDC_MaxLaneGuidanceStorageCapacity              8    // See the Accessory Interface Specification for more information.

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationRejected

#define IAP2_AI_IR_Name                                                                     0
#define IAP2_AI_IR_ModelIdentifier                                                          1
#define IAP2_AI_IR_Manufacturer                                                             2
#define IAP2_AI_IR_SerialNumber                                                             3
#define IAP2_AI_IR_FirmwareVersion                                                          4
#define IAP2_AI_IR_HardwareVersion                                                          5
#define IAP2_AI_IR_MessagesSentByAccessory                                                  6
#define IAP2_AI_IR_MessagesReceivedFromDevice                                               7
#define IAP2_AI_IR_PowerProvidingCapability                                                 8
#define IAP2_AI_IR_MaximumCurrentDrawnFromDevice                                            9
#define IAP2_AI_IR_SupportedExternalAccessoryProtocol                                       10
#define IAP2_AI_IR_AppMatchTeamID                                                           11
#define IAP2_AI_IR_CurrentLanguage                                                          12
#define IAP2_AI_IR_SupportedLanguage                                                        13
#define IAP2_AI_IR_SerialTransportComponent                                                 14
#define IAP2_AI_IR_USBDeviceTransportComponent                                              15
#define IAP2_AI_IR_USBHostTransportComponent                                                16
#define IAP2_AI_IR_BluetoothTransportComponent                                              17
#define IAP2_AI_IR_iAP2HIDComponent                                                         18
#define IAP2_AI_IR_VehicleInformationComponent                                              20
#define IAP2_AI_IR_VehicleStatusComponent                                                   21
#define IAP2_AI_IR_LocationInformationComponent                                             22
#define IAP2_AI_IR_USBHostHIDComponent                                                      23
#define IAP2_AI_IR_WirelessCarPlayTransportComponent                                        24
#define IAP2_AI_IR_BluetoothHIDComponent                                                    29
#define IAP2_AI_IR_RouteGuidanceDisplayComponent                                            30
#define IAP2_AI_IR_ProductPlanUID                                                           34

//**************************************************************************************
// IAP2 message, Accessory Identification, IdentificationInformationUpdate

#define IAP2_AI_IIU_Name                                                                    0
#define IAP2_AI_IIU_ModelIdentifier                                                         1
#define IAP2_AI_IIU_Manufacturer                                                            2
#define IAP2_AI_IIU_SerialNumber                                                            3
#define IAP2_AI_IIU_FirmwareVersion                                                         4
#define IAP2_AI_IIU_HardwareVersion                                                         5
#define IAP2_AI_IIU_CurrentLanguage                                                         6

//**************************************************************************************
// IAP2 message, App Launch

#define IAP2_APP_LAUNCH                                                                     0xEA

#define IAP2_AL_RequestAppLaunch                                                            0x02

//**************************************************************************************
// IAP2 message, App Launch, RequestAppLaunch

#define IAP2_AL_RAL_AppBundleID                                                             0
#define IAP2_AL_RAL_AppLaunchMethod                                                         1

//**************************************************************************************
// IAP2 message, Assistive Touch

#define IAP2_ASSISTIVE_TOUCH                                                                0x54

#define IAP2_AT_StartAssistiveTouch                                                         0x00
#define IAP2_AT_StopAssistiveTouch                                                          0x01
#define IAP2_AT_StartAssistiveTouchInformation                                              0x02
#define IAP2_AT_AssistiveTouchInformation                                                   0x03
#define IAP2_AT_StopAssistiveTouchInformation                                               0x04

//**************************************************************************************
// IAP2 message, Assistive Touch, AssistiveTouchInformation

#define IAP2_AT_ATI_IsEnabled                                                               0

//**************************************************************************************
// IAP2 message, Bluetooth Connection

#define IAP2_BLUETOOTH_CONNECTION                                                           0x4E

#define IAP2_BC_BluetoothComponentInformation                                               0x01
#define IAP2_BC_StartBluetoothConnectionUpdates                                             0x03
#define IAP2_BC_BluetoothConnectionUpdate                                                   0x04
#define IAP2_BC_StopBluetoothConnectionUpdates                                              0x05

//**************************************************************************************
// IAP2 message, Bluetooth Connection, BluetoothComponentInformation

#define IAP2_BC_BCI_BluetoothComponentStatus                                                0

//**************************************************************************************
// IAP2 message, Bluetooth Connection, BluetoothComponentInformation, BluetoothComponentStatus

#define IAP2_BC_BCI_BCS_ComponentIdentifier                                                 0
#define IAP2_BC_BCI_BCS_ComponentEnabled                                                    1

//**************************************************************************************
// IAP2 message, Bluetooth Connection, StartBluetoothConnectionUpdates

#define IAP2_BC_SBCU_BluetoothTransportComponentIdentifier                                  0

//**************************************************************************************
// IAP2 message, Bluetooth Connection, BluetoothConnectionUpdate

#define IAP2_BC_BCU_BluetoothTransportComponentIdentifier                                   0
#define IAP2_BC_BCU_ConnectedBluetoothProfiles                                              1

//**************************************************************************************
// IAP2 message, Bluetooth Connection, BluetoothConnectionUpdate, BluetoothComponentProfiles

#define IAP2_BC_BCU_BCP_BluetoothHandsFree                                                  0
#define IAP2_BC_BCU_BCP_BluetoothPhoneBookAccess                                            1
#define IAP2_BC_BCU_BCP_BluetoothAudioVideoRemoteControl                                    3
#define IAP2_BC_BCU_BCP_BluetoothAdvancedAudioDistribution                                  4
#define IAP2_BC_BCU_BCP_BluetoothHumanInterfaceDevice                                       5
#define IAP2_BC_BCU_BCP_BluetoothiAP2Link                                                   7
#define IAP2_BC_BCU_BCP_BluetoothPersonalAreaNetworkAccessPoint                             8
#define IAP2_BC_BCU_BCP_BluetoothMessageAccess                                              9
#define IAP2_BC_BCU_BCP_BluetoothPersonalAreaNetworkClient                                  12

//**************************************************************************************
// IAP2 message, Communications

#define IAP2_COMMUNICATIONS                                                                 0x41

#define IAP2_C_StartCallStateUpdates                                                        0x54
#define IAP2_C_CallStateUpdate                                                              0x55
#define IAP2_C_StopCallStateUpdates                                                         0x56
#define IAP2_C_StartCommunicationsUpdates                                                   0x57
#define IAP2_C_CommunicationsUpdate                                                         0x58
#define IAP2_C_StopCommunicationsUpdates                                                    0x59
#define IAP2_C_InitiateCall                                                                 0x5A
#define IAP2_C_AcceptCall                                                                   0x5B
#define IAP2_C_EndCall                                                                      0x5C
#define IAP2_C_SwapCalls                                                                    0x5D
#define IAP2_C_MergeCalls                                                                   0x5E
#define IAP2_C_HoldStatusUpdate                                                             0x5F
#define IAP2_C_MuteStatusUpdate                                                             0x60
#define IAP2_C_SendDTMF                                                                     0x61
#define IAP2_C_StartListUpdates                                                             0x70
#define IAP2_C_ListUpdate                                                                   0x71
#define IAP2_C_StopListUpdates                                                              0x72

//**************************************************************************************
// IAP2 message, Communications, StartCallStateUpdates

#define IAP2_C_SCSU_RemoteID                                                                0
#define IAP2_C_SCSU_DisplayName                                                             1
#define IAP2_C_SCSU_Status                                                                  2
#define IAP2_C_SCSU_Direction                                                               3
#define IAP2_C_SCSU_CallUUID                                                                4
#define IAP2_C_SCSU_AddressBookID                                                           6
#define IAP2_C_SCSU_Label                                                                   7
#define IAP2_C_SCSU_Service                                                                 8
#define IAP2_C_SCSU_IsConferenced                                                           9
#define IAP2_C_SCSU_ConferenceGroup                                                         10
#define IAP2_C_SCSU_DisconnectReason                                                        11
#define IAP2_C_SCSU_StartTimestamp                                                          12

//**************************************************************************************
// IAP2 message, Communications, CallStateUpdate

#define IAP2_C_CSU_RemoteID                                                                 0
#define IAP2_C_CSU_DisplayName                                                              1
#define IAP2_C_CSU_Status                                                                   2
#define IAP2_C_CSU_Direction                                                                3
#define IAP2_C_CSU_CallUUID                                                                 4
#define IAP2_C_CSU_AddressBookID                                                            6
#define IAP2_C_CSU_Label                                                                    7
#define IAP2_C_CSU_Service                                                                  8
#define IAP2_C_CSU_IsConferenced                                                            9
#define IAP2_C_CSU_ConferenceGroup                                                          10
#define IAP2_C_CSU_DisconnectReason                                                         11

//**************************************************************************************
// IAP2 message, Communications, StartCommunicationsUpdates

#define IAP2_C_SCU_SignalStrength                                                           0
#define IAP2_C_SCU_RegistrationStatus                                                       1
#define IAP2_C_SCU_AirplaneModeStatus                                                       2
#define IAP2_C_SCU_CarrierName                                                              4
#define IAP2_C_SCU_CellularSupported                                                        5
#define IAP2_C_SCU_TelephonyEnabled                                                         6
#define IAP2_C_SCU_FaceTimeAudioEnabled                                                     7
#define IAP2_C_SCU_FaceTimeVideoEnabled                                                     8
#define IAP2_C_SCU_MuteStatus                                                               9
#define IAP2_C_SCU_CurrentCallCount                                                         10
#define IAP2_C_SCU_NewVoicemailCount                                                        11
#define IAP2_C_SCU_InitiateCallAvailable                                                    12
#define IAP2_C_SCU_EndAndAcceptAvailable                                                    13
#define IAP2_C_SCU_HoldAndAcceptAvailable                                                   14
#define IAP2_C_SCU_SwapAvailable                                                            15
#define IAP2_C_SCU_MergeAvailable                                                           16
#define IAP2_C_SCU_HoldAvailable                                                            17

//**************************************************************************************
// IAP2 message, Communications, CommunicationsUpdate

#define IAP2_C_CU_SignalStrength                                                            0
#define IAP2_C_CU_RegistrationStatus                                                        1
#define IAP2_C_CU_AirplaneModeStatus                                                        2
#define IAP2_C_CU_CarrierName                                                               4
#define IAP2_C_CU_CellularSupported                                                         5
#define IAP2_C_CU_TelephonyEnabled                                                          6
#define IAP2_C_CU_FaceTimeAudioEnabled                                                      7
#define IAP2_C_CU_FaceTimeVideoEnabled                                                      8
#define IAP2_C_CU_MuteStatus                                                                9
#define IAP2_C_CU_CurrentCallCount                                                          10
#define IAP2_C_CU_NewVoicemailCount                                                         11
#define IAP2_C_CU_InitiateCallAvailable                                                     12
#define IAP2_C_CU_EndAndAcceptAvailable                                                     13
#define IAP2_C_CU_HoldAndAcceptAvailable                                                    14
#define IAP2_C_CU_SwapAvailable                                                             15
#define IAP2_C_CU_MergeAvailable                                                            16
#define IAP2_C_CU_HoldAvailable                                                             17

//**************************************************************************************
// IAP2 message, Communications, InitiateCall

#define IAP2_C_IC_Type                                                                      0
#define IAP2_C_IC_DestinationID                                                             1
#define IAP2_C_IC_Service                                                                   2
#define IAP2_C_IC_AddressBookID                                                             3

//**************************************************************************************
// IAP2 message, Communications, AcceptCall

#define IAP2_C_AC_AcceptAction                                                              0
#define IAP2_C_AC_CallUUID                                                                  1

//**************************************************************************************
// IAP2 message, Communications, EndCall

#define IAP2_C_EC_EndAction                                                                 0
#define IAP2_C_EC_CallUUID                                                                  1

//**************************************************************************************
// IAP2 message, Communications, HoldStatusUpdate

#define IAP2_C_HSU_HoldStatus                                                               0
#define IAP2_C_HSU_CallUUID                                                                 1

//**************************************************************************************
// IAP2 message, Communications, MuteStatusUpdate

#define IAP2_C_MSU_MuteStatus                                                               0

//**************************************************************************************
// IAP2 message, Communications, SendDTMF

#define IAP2_C_SDTMF_Tone                                                                   0
#define IAP2_C_SDTMF_CallUUID                                                               1

//**************************************************************************************
// IAP2 message, Communications, StartListUpdates

#define IAP2_C_SLU_RecentsListProperties                                                    1
#define IAP2_C_SLU_RecentsListMax                                                           3
#define IAP2_C_SLU_RecentsListCombine                                                       4
#define IAP2_C_SLU_FavoritesListProperties                                                  6
#define IAP2_C_SLU_FavoritesListMax                                                         8

//**************************************************************************************
// IAP2 message, Communications, StartListUpdates, RecentsListProperties

#define IAP2_C_SLU_RLP_Index                                                                0
#define IAP2_C_SLU_RLP_RemoteID                                                             1
#define IAP2_C_SLU_RLP_DisplayName                                                          2
#define IAP2_C_SLU_RLP_Label                                                                3
#define IAP2_C_SLU_RLP_AddressBookID                                                        4
#define IAP2_C_SLU_RLP_Service                                                              5
#define IAP2_C_SLU_RLP_Type                                                                 6
#define IAP2_C_SLU_RLP_UnixTimestamp                                                        7
#define IAP2_C_SLU_RLP_Duration                                                             8
#define IAP2_C_SLU_RLP_Occurrences                                                          9

//**************************************************************************************
// IAP2 message, Communications, StartListUpdates, FavoritesListProperties

#define IAP2_C_SLU_FLP_Index                                                                0
#define IAP2_C_SLU_FLP_RemoteID                                                             1
#define IAP2_C_SLU_FLP_DisplayName                                                          2
#define IAP2_C_SLU_FLP_Label                                                                3
#define IAP2_C_SLU_FLP_AddressBookID                                                        4
#define IAP2_C_SLU_FLP_Service                                                              5

//**************************************************************************************
// IAP2 message, Communications, ListUpdate

#define IAP2_C_LU_RecentsListAvailable                                                      0
#define IAP2_C_LU_RecentsList                                                               1
#define IAP2_C_LU_RecentsListCount                                                          2
#define IAP2_C_LU_FavoritesListAvailable                                                    5
#define IAP2_C_LU_FavoritesList                                                             6
#define IAP2_C_LU_FavoritesListCount                                                        7

//**************************************************************************************
// IAP2 message, Communications, ListUpdate, RecentsList

#define IAP2_C_LU_RL_Index                                                                  0
#define IAP2_C_LU_RL_RemoteID                                                               1
#define IAP2_C_LU_RL_DisplayName                                                            2
#define IAP2_C_LU_RL_Label                                                                  3
#define IAP2_C_LU_RL_AddressBookID                                                          4
#define IAP2_C_LU_RL_Service                                                                5
#define IAP2_C_LU_RL_Type                                                                   6
#define IAP2_C_LU_RL_UnixTimestamp                                                          7
#define IAP2_C_LU_RL_Duration                                                               8
#define IAP2_C_LU_RL_Occurrences                                                            9

//**************************************************************************************
// IAP2 message, Communications, ListUpdate, FavoritesList

#define IAP2_C_LU_FL_Index                                                                  0
#define IAP2_C_LU_FL_RemoteID                                                               1
#define IAP2_C_LU_FL_DisplayName                                                            2
#define IAP2_C_LU_FL_Label                                                                  3
#define IAP2_C_LU_FL_AddressBookID                                                          4
#define IAP2_C_LU_FL_Service                                                                5

//**************************************************************************************
// IAP2 message, Device Authentication

#define IAP2_DEVICE_AUTHENICATION                                                           0xAA

#define IAP2_DA_RequestDeviceAuthenticationCertificate                                      0x10
#define IAP2_DA_DeviceAuthenticationCertificate                                             0x11
#define IAP2_DA_RequestDeviceAuthenticationChallengeResponse                                0x12
#define IAP2_DA_DeviceAuthenticationResponse                                                0x13
#define IAP2_DA_DeviceAuthenticationFailed                                                  0x14
#define IAP2_DA_DeviceAuthenticationSucceeded                                               0x15

//**************************************************************************************
// IAP2 message, Device Authentication, DeviceAuthenticationCertificate

#define IAP2_DA_DAC_DeviceAuthenticationCertificate                                         0

//**************************************************************************************
// IAP2 message, Device Authentication, RequestDeviceAuthenticationChallengeResponse

#define IAP2_DA_DAC_RDACR_DeviceAuthenticationChallenge                                     0

//**************************************************************************************
// IAP2 message, Device Authentication, DeviceAuthenticationResponse

#define IAP2_DA_DAR_DeviceAuthenticationResponse                                            0

//**************************************************************************************
// IAP2 message, Device Notifications

#define IAP2_DEVICE_NOTIFICATIONS                                                           0x4E

#define IAP2_DN_DeviceInformationUpdate                                                     0x09
#define IAP2_DN_DeviceLanguageUpdate                                                        0x0A
#define IAP2_DN_DeviceTimeUpdate                                                            0x0B
#define IAP2_DN_DeviceUUIDUpdate                                                            0x0C
#define IAP2_DN_WirelessCarPlayUpdate                                                       0x0D
#define IAP2_DN_DeviceTransportIdentifierNotification                                       0x0E

//**************************************************************************************
// IAP2 message, Device Notifications, DeviceInformationUpdate

#define IAP2_DN_DIU_DeviceName                                                              0

//**************************************************************************************
// IAP2 message, Device Notifications, DeviceLanguageUpdate

#define IAP2_DN_DLU_DeviceLanguage                                                          0

//**************************************************************************************
// IAP2 message, Device Notifications, DeviceTimeUpdate

#define IAP2_DN_DTU_SecondsSinceReferenceDate                                               0
#define IAP2_DN_DTU_TimeZoneOffsetMinutes                                                   1
#define IAP2_DN_DTU_DaylightSavingsOffsetMinutes                                            2

//**************************************************************************************
// IAP2 message, Device Notifications, DeviceUUIDUpdate

#define IAP2_DN_DUUIDU_UUID                                                                 0

//**************************************************************************************
// IAP2 message, Device Notifications, WirelessCarPlayUpdate

#define IAP2_DN_WCU_Status                                                                  0

//**************************************************************************************
// IAP2 message, Device Notifications, DeviceTransportIdentifierNotification

#define IAP2_DN_DTIN_BluetoothTransportIdentifier                                           0
#define IAP2_DN_DTIN_USBTransportIdentifier                                                 1

//**************************************************************************************
// IAP2 message, External Accessory Protocol

#define IAP2_EXTERNAL_ACCESSORY_PROTOCOL                                                    0xEA

#define IAP2_EAP_StartExternalAccessoryProtocolSession                                      0x00
#define IAP2_EAP_StopExternalAccessoryProtocolSession                                       0x01
#define IAP2_EAP_StatusExternalAccessoryProtocolSession                                     0x03

//**************************************************************************************
// IAP2 message, External Accessory Protocol, StartExternalAccessoryProtocolSession

#define IAP2_EAP_StrEAPS_ExternalAccessoryProtocolIdentifier                                0
#define IAP2_EAP_StrEAPS_ExternalAccessoryProtocolSessionIdentifier                         1

//**************************************************************************************
// IAP2 message, External Accessory Protocol, StopExternalAccessoryProtocolSession

#define IAP2_EAP_StpEAPS_ExternalAccessoryProtocolSessionIdentifier                         0

//**************************************************************************************
// IAP2 message, External Accessory Protocol, StatusExternalAccessoryProtocolSession

#define IAP2_EAP_StuEAPS_ExternalAccessoryProtocolSessionIdentifier                         0
#define IAP2_EAP_StuEAPS_ExternalAccessoryProtocolSessionStatus                             1

//**************************************************************************************
// IAP2 message, Human Interface Device

#define IAP2_HID                                                                            0x68

#define IAP2_HID_StartHID                                                                   0x00
#define IAP2_HID_DeviceHIDReport                                                            0x01
#define IAP2_HID_AccessoryHIDReport                                                         0x02
#define IAP2_HID_StopHID                                                                    0x03
#define IAP2_HID_StartNativeHID                                                             0x06

//**************************************************************************************
// IAP2 message, Human Interface Device, StartHID

#define IAP2_HID_StrHID_HIDComponentIdentifier                                              0
#define IAP2_HID_StrHID_VendorIdentifier                                                    1
#define IAP2_HID_StrHID_ProductIdentifier                                                   2
#define IAP2_HID_StrHID_LocalizedKeyboardCountryCode                                        3
#define IAP2_HID_StrHID_HIDReportDescriptor                                                 4

//**************************************************************************************
// IAP2 message, Human Interface Device, DeviceHIDReport

#define IAP2_HID_DHIDR_HIDComponentIdentifier                                               0
#define IAP2_HID_DHIDR_HIDReport                                                            1

//**************************************************************************************
// IAP2 message, Human Interface Device, AccessoryHIDReport

#define IAP2_HID_AHIDR_HIDComponentIdentifier                                               0
#define IAP2_HID_AHIDR_HIDReport                                                            1

//**************************************************************************************
// IAP2 message, Human Interface Device, StopHID

#define IAP2_HID_StpHID_HIDComponentIdentifier                                              0

//**************************************************************************************
// IAP2 message, Location

#define IAP2_LOCATION                                                                       0xFF

#define IAP2_L_StartLocationInformation                                                     0xFA
#define IAP2_L_GPRMCDDataStatusValuesNotification                                           0xF0
#define IAP2_L_LocationInformation                                                          0xFB
#define IAP2_L_StopLocationInformation                                                      0xFC

//**************************************************************************************
// IAP2 message, Location, StartLocationInformation

#define IAP2_L_SLI_GlobalPositioningSystemFixData                                           1
#define IAP2_L_SLI_RecommendedMinimumSpecificGPSTransitData                                 2
#define IAP2_L_SLI_GPSSatellitesInView                                                      3
#define IAP2_L_SLI_VehicleSpeedData                                                         4
#define IAP2_L_SLI_VehicleGyroData                                                          5
#define IAP2_L_SLI_VehicleAccelerometerData                                                 6
#define IAP2_L_SLI_VehicleHeadingData                                                       7

#define IAP2_L_SLI_GlobalPositioningSystemFixData_Sent                                      17
#define IAP2_L_SLI_RecommendedMinimumSpecificGPSTransitData_Sent                            18
#define IAP2_L_SLI_GPSSatellitesInView_Sent                                                 19
#define IAP2_L_SLI_VehicleSpeedData_Sent                                                    20
#define IAP2_L_SLI_VehicleGyroData_Sent                                                     21
#define IAP2_L_SLI_VehicleAccelerometerData_Sent                                            22
#define IAP2_L_SLI_VehicleHeadingData_Sent                                                  23

//**************************************************************************************
// IAP2 message, Location, GPRMCDDataStatusValuesNotification

#define IAP2_L_GPRMCDDSVN_GPRMCDDataStatusValueA                                            0
#define IAP2_L_GPRMCDDSVN_GPRMCDDataStatusValueV                                            1
#define IAP2_L_GPRMCDDSVN_GPRMCDDataStatusValueX                                            2

//**************************************************************************************
// IAP2 message, Location, LocationInformation

#define IAP2_L_LI_NMEASentence                                                              0

//**************************************************************************************
// IAP2 message, Media Library Access

#define IAP2_MEDIA_LIBRARY_ACCESS                                                           0x4C

#define IAP2_MLA_StartMediaLibraryInformation                                               0x00
#define IAP2_MLA_MediaLibraryInformation                                                    0x01
#define IAP2_MLA_StopMediaLibraryInformation                                                0x02
#define IAP2_MLA_StartMediaLibraryUpdates                                                   0x03
#define IAP2_MLA_MediaLibraryUpdate                                                         0x04
#define IAP2_MLA_StopMediaLibraryUpdates                                                    0x05
#define IAP2_MLA_PlayMediaLibraryCurrentSelection                                           0x06
#define IAP2_MLA_PlayMediaLibraryItems                                                      0x07
#define IAP2_MLA_PlayMediaLibraryCollection                                                 0x08
#define IAP2_MLA_PlayMediaLibrarySpecial                                                    0x09

//**************************************************************************************
// IAP2 message, Media Library Access, MediaLibraryInformation

#define IAP2_MLA_MLI_MediaLibraryInformation                                                0

//**************************************************************************************
// IAP2 message, Media Library Access, MediaLibraryInformation, MediaLibraryInformation

#define IAP2_MLA_MLI_MLI_MediaLibraryName                                                   0
#define IAP2_MLA_MLI_MLI_MediaLibraryUniqueIdentifier                                       1
#define IAP2_MLA_MLI_MLI_MediaLibraryType                                                   2

//**************************************************************************************
// IAP2 message, Media Library Access, StartMediaLibraryUpdates

#define IAP2_MLA_SMLU_MediaLibraryUniqueIdentifier                                          0
#define IAP2_MLA_SMLU_LastKnownMediaLibraryRevision                                         1
#define IAP2_MLA_SMLU_MediaItemProperties                                                   2
#define IAP2_MLA_SMLU_MediaPlaylistProperties                                               3
#define IAP2_MLA_SMLU_MediaLibraryUpdateProgress                                            4
#define IAP2_MLA_SMLU_MediaLibraryIsHidingRemoteItems                                       5
#define IAP2_MLA_SMLU_PlayAllSongsCapable                                                   6

//**************************************************************************************
// IAP2 message, Media Library Access, StartMediaLibraryUpdates, MediaItemProperties

#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyPersistentIdentifier                           0
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyTitle                                          1
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyMediaType                                      2
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyRating                                         3
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyPlaybackDurationInMilliseconds                 4
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyAlbumPersistentIdentifer                       5
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyAlbumTitle                                     6
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyAlbumTrackNumber                               7
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyAlbumTrackCount                                8
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyAlbumDiscNumber                                9
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyAlbumDiscCount                                 10
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyArtistPersistentIdentifier                     11
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyArtist                                         12
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyAlbumArtistPersistentIdentifier                13
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyAlbumArtist                                    14
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyGenrePersistentIdentifier                      15
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyGenre                                          16
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyComposerPersistentIdentifier                   17
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyComposer                                       18
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyIsPartOfCompilation                            19
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyIsResidentOnDevice                             25
#define IAP2_MLA_SrMLU_MIP_MediaItemPropertyChapterCount                                   27

//**************************************************************************************
// IAP2 message, Media Library Access, StartMediaLibraryUpdates, MediaPlaylistProperties

#define IAP2_MLA_SrMLU_MPP_MediaPlaylistPropertyPersistentIdentifer                        0
#define IAP2_MLA_SrMLU_MPP_MediaPlaylistPropertyName                                       1
#define IAP2_MLA_SrMLU_MPP_MediaPlaylistPropertyParentPersistentIdentifer                  2
#define IAP2_MLA_SrMLU_MPP_MediaPlaylistPropertyIsGeniusMix                                3
#define IAP2_MLA_SrMLU_MPP_MediaPlaylistPropertyIsFolder                                   4
#define IAP2_MLA_SrMLU_MPP_MediaPlaylistPropertyContainedMediaItemsFileTransferIdentifier  5
#define IAP2_MLA_SrMLU_MPP_MediaPlaylistPropertyIsAppleMusicRadioStation                   6
#define IAP2_MLA_SrMLU_MPP_MediaPlaylistPropertyMediaPlaylistContentTransfer               7

//**************************************************************************************
// IAP2 message, Media Library Access, MediaLibraryUpdate

#define IAP2_MLA_MLU_MediaLibraryUniqueIdentifier                                           0
#define IAP2_MLA_MLU_MediaLibraryRevision                                                   1
#define IAP2_MLA_MLU_MediaItem                                                              2
#define IAP2_MLA_MLU_MediaPlaylist                                                          3
#define IAP2_MLA_MLU_MediaItemDeletePersistentIdentifier                                    4
#define IAP2_MLA_MLU_MediaPlaylistDeletePersistentIdentifier                                5
#define IAP2_MLA_MLU_MediaLibraryReset                                                      6
#define IAP2_MLA_MLU_MediaLibraryUpdateProgress                                             7
#define IAP2_MLA_MLU_MediaLibraryIsHidingRemoteItems                                        8
#define IAP2_MLA_MLU_PlayAllSongsCapable                                                    9

//**************************************************************************************
// IAP2 message, Media Library Access, MediaLibraryUpdate, MediaItem

#define IAP2_MLA_MLU_MI_MediaItemPersistentIdentifier                                       0
#define IAP2_MLA_MLU_MI_MediaItemTitle                                                      1
#define IAP2_MLA_MLU_MI_MediaItemMediaType                                                  2
#define IAP2_MLA_MLU_MI_MediaItemRating                                                     3
#define IAP2_MLA_MLU_MI_MediaItemPlaybackDurationInMilliseconds                             4
#define IAP2_MLA_MLU_MI_MediaItemAlbumPersistentIdentifer                                   5
#define IAP2_MLA_MLU_MI_MediaItemAlbumTitle                                                 6
#define IAP2_MLA_MLU_MI_MediaItemAlbumTrackNumber                                           7
#define IAP2_MLA_MLU_MI_MediaItemAlbumTrackCount                                            8
#define IAP2_MLA_MLU_MI_MediaItemAlbumDiscNumber                                            9
#define IAP2_MLA_MLU_MI_MediaItemAlbumDiscCount                                             10
#define IAP2_MLA_MLU_MI_MediaItemArtistPersistentIdentifier                                 11
#define IAP2_MLA_MLU_MI_MediaItemArtist                                                     12
#define IAP2_MLA_MLU_MI_MediaItemAlbumArtistPersistentIdentifier                            13
#define IAP2_MLA_MLU_MI_MediaItemAlbumArtist                                                14
#define IAP2_MLA_MLU_MI_MediaItemGenrePersistentIdentifier                                  15
#define IAP2_MLA_MLU_MI_MediaItemGenre                                                      16
#define IAP2_MLA_MLU_MI_MediaItemComposerPersistentIdentifier                               17
#define IAP2_MLA_MLU_MI_MediaItemComposer                                                   18
#define IAP2_MLA_MLU_MI_MediaItemIsPartOfCompilation                                        19
#define IAP2_MLA_MLU_MI_MediaItemIsLikeSupported                                            21
#define IAP2_MLA_MLU_MI_MediaItemIsBanSupported                                             22
#define IAP2_MLA_MLU_MI_MediaItemIsLiked                                                    23
#define IAP2_MLA_MLU_MI_MediaItemIsBanned                                                   24
#define IAP2_MLA_MLU_MI_MediaItemIsResidentOnDevice                                         25
#define IAP2_MLA_MLU_MI_MediaItemArtworkFileTransferIdentifier                              26
#define IAP2_MLA_MLU_MI_MediaItemChapterCount                                               27

//**************************************************************************************
// IAP2 message, Media Library Access, MediaLibraryUpdate, MediaPlaylist

#define IAP2_MLA_MLU_MP_MediaPlaylistPersistentIdentifer                                    0
#define IAP2_MLA_MLU_MP_MediaPlaylistName                                                   1
#define IAP2_MLA_MLU_MP_MediaPlaylistParentPersistentIdentifer                              2
#define IAP2_MLA_MLU_MP_MediaPlaylistIsGeniusMix                                            3
#define IAP2_MLA_MLU_MP_MediaPlaylistIsFolder                                               4
#define IAP2_MLA_MLU_MP_MediaPlaylistContainedMediaItemsFileTransferIdentifier              5
#define IAP2_MLA_MLU_MP_MediaPlaylistIsAppleMusicRadioStation                               6
#define IAP2_MLA_MLU_MP_MediaPlaylistContentTransfer                                        7

//**************************************************************************************
// IAP2 message, Media Library Access, StopMediaLibraryUpdates

#define IAP2_MLA_StpMLU_MediaLibraryUniqueIdentifier                                        0

//**************************************************************************************
// IAP2 message, Media Library Access, PlayMediaLibraryCurrentSelection

#define IAP2_MLA_PMLCS_MediaLibraryUniqueIdentifier                                         0

//**************************************************************************************
// IAP2 message, Media Library Access, PlayMediaLibraryItems

#define IAP2_MLA_PMLI_ItemsPersistentIdentifiers                                            0
#define IAP2_MLA_PMLI_ItemsStartingIndex                                                    1
#define IAP2_MLA_PMLI_MediaLibraryUniqueIdentifier                                          2

//**************************************************************************************
// IAP2 message, Media Library Access, PlayMediaLibraryCollection

#define IAP2_MLA_PMLC_CollectionPersistentIdentifier                                        0
#define IAP2_MLA_PMLC_CollectionType                                                        1
#define IAP2_MLA_PMLC_CollectionStartingIndex                                               2
#define IAP2_MLA_PMLC_MediaLibraryUniqueIdentifier                                          3

//**************************************************************************************
// IAP2 message, Media Library Access, PlayMediaLibrarySpecial

#define IAP2_MLA_PMLS_MediaLibraryUniqueIdentifier                                          0
#define IAP2_MLA_PMLS_AllSongs                                                              1

//**************************************************************************************
// IAP2 message, Now Playing

#define IAP2_NOW_PLAYING                                                                    0x50

#define IAP2_NP_StartNowPlayingUpdates                                                      0x00
#define IAP2_NP_NowPlayingUpdate                                                            0x01
#define IAP2_NP_StopNowPlayingUpdates                                                       0x02
#define IAP2_NP_SetNowPlayingInformation                                                    0x03

//**************************************************************************************
// IAP2 message, Now Playing, StartNowPlayingUpdates

#define IAP2_NP_SNPU_MediaItemAttributes                                                    0
#define IAP2_NP_SNPU_PlaybackAttributes                                                     1
#define IAP2_NP_SNPU_PlaybackQueueListContentTransferInfoRequest                            2

//**************************************************************************************
// IAP2 message, Now Playing, StartNowPlayingUpdates, MediaItemAttributes

#define IAP2_NP_SNPU_MIA_MediaItemPersistentIdentifier                                      0
#define IAP2_NP_SNPU_MIA_MediaItemTitle                                                     1
#define IAP2_NP_SNPU_MIA_MediaItemPlaybackDurationInMilliseconds                            4
#define IAP2_NP_SNPU_MIA_MediaItemAlbumTitle                                                6
#define IAP2_NP_SNPU_MIA_MediaItemAlbumTrackNumber                                          7
#define IAP2_NP_SNPU_MIA_MediaItemAlbumTrackCount                                           8
#define IAP2_NP_SNPU_MIA_MediaItemAlbumDiscNumber                                           9
#define IAP2_NP_SNPU_MIA_MediaItemAlbumDiscCount                                            10
#define IAP2_NP_SNPU_MIA_MediaItemArtist                                                    12
#define IAP2_NP_SNPU_MIA_MediaItemGenre                                                     16
#define IAP2_NP_SNPU_MIA_MediaItemComposer                                                  18
#define IAP2_NP_SNPU_MIA_MediaItemIsLikeSupported                                           21
#define IAP2_NP_SNPU_MIA_MediaItemIsBanSupported                                            22
#define IAP2_NP_SNPU_MIA_MediaItemIsLiked                                                   23
#define IAP2_NP_SNPU_MIA_MediaItemIsBanned                                                  24
#define IAP2_NP_SNPU_MIA_MediaItemArtworkFileTransferIdentifier                             26
#define IAP2_NP_SNPU_MIA_MediaItemChapterCount                                              27

//**************************************************************************************
// IAP2 message, Now Playing, StartNowPlayingUpdates, PlaybackAttributes

#define IAP2_NP_SNPU_PA_PlaybackStatus                                                      0
#define IAP2_NP_SNPU_PA_PlaybackElapsedTimeInMilliseconds                                   1
#define IAP2_NP_SNPU_PA_PlaybackQueueIndex                                                  2
#define IAP2_NP_SNPU_PA_PlaybackQueueCount                                                  3
#define IAP2_NP_SNPU_PA_PlaybackQueueChapterIndex                                           4
#define IAP2_NP_SNPU_PA_PlaybackShuffleMode                                                 5
#define IAP2_NP_SNPU_PA_PlaybackRepeatMode                                                  6
#define IAP2_NP_SNPU_PA_PlaybackAppName                                                     7
#define IAP2_NP_SNPU_PA_PlaybackMediaLibraryUniqueIdentifier                                8
#define IAP2_NP_SNPU_PA_PBAppleMusicRadioAd                                                 9
#define IAP2_NP_SNPU_PA_PBAppleMusicRadioStationName                                        10
#define IAP2_NP_SNPU_PA_PBAppleMusicRadioStationMediaPlaylistID                             11
#define IAP2_NP_SNPU_PA_PlaybackSpeed                                                       12
#define IAP2_NP_SNPU_PA_SetElapsedTimeAvailable                                             13
#define IAP2_NP_SNPU_PA_PlaybackQueueListAvail                                              14
#define IAP2_NP_SNPU_PA_PlaybackQueueListTransferID                                         15
#define IAP2_NP_SNPU_PA_PlaybackAppBundleID                                                 16
#define IAP2_NP_SNPU_PA_PlaybackQueueListContentTransferSize                                17

//**************************************************************************************
// IAP2 message, Now Playing, StartNowPlayingUpdates, PlaybackQueueListContentTransferInfoRequest

#define IAP2_NP_SNPU_PQCTIR_MediaItemPID                                                    0
#define IAP2_NP_SNPU_PQCTIR_MediaItemTitle                                                  1
#define IAP2_NP_SNPU_PQCTIR_MediaItemAlbumTitle                                             6
#define IAP2_NP_SNPU_PQCTIR_MediaItemArtist                                                 12
#define IAP2_NP_SNPU_PQCTIR_MediaItemAlbumArtist                                            14
#define IAP2_NP_SNPU_PQCTIR_MediaItemGenre                                                  16
#define IAP2_NP_SNPU_PQCTIR_MediaItemComposer                                               18

//**************************************************************************************
// IAP2 message, Now Playing, NowPlayingUpdate

#define IAP2_NP_NPU_MediaItemAttributes                                                     0
#define IAP2_NP_NPU_PlaybackAttributes                                                      1

//**************************************************************************************
// IAP2 message, Now Playing, NowPlayingUpdate, MediaItemAttributes

#define IAP2_NP_NPU_MIA_MediaItemPersistentIdentifier                                       0
#define IAP2_NP_NPU_MIA_MediaItemTitle                                                      1
#define IAP2_NP_NPU_MIA_MediaItemPlaybackDurationInMilliseconds                             4
#define IAP2_NP_NPU_MIA_MediaItemAlbumTitle                                                 6
#define IAP2_NP_NPU_MIA_MediaItemAlbumTrackNumber                                           7
#define IAP2_NP_NPU_MIA_MediaItemAlbumTrackCount                                            8
#define IAP2_NP_NPU_MIA_MediaItemAlbumDiscNumber                                            9
#define IAP2_NP_NPU_MIA_MediaItemAlbumDiscCount                                             10
#define IAP2_NP_NPU_MIA_MediaItemArtist                                                     12
#define IAP2_NP_NPU_MIA_MediaItemGenre                                                      16
#define IAP2_NP_NPU_MIA_MediaItemComposer                                                   18
#define IAP2_NP_NPU_MIA_MediaItemIsLikeSupported                                            21
#define IAP2_NP_NPU_MIA_MediaItemIsBanSupported                                             22
#define IAP2_NP_NPU_MIA_MediaItemIsLiked                                                    23
#define IAP2_NP_NPU_MIA_MediaItemIsBanned                                                   24
#define IAP2_NP_NPU_MIA_MediaItemArtworkFileTransferIdentifier                              26
#define IAP2_NP_NPU_MIA_MediaItemChapterCount                                               27

//**************************************************************************************
// IAP2 message, Now Playing, NowPlayingUpdate, PlaybackAttributes

#define IAP2_NP_NPU_PA_PlaybackStatus                                                       0
#define IAP2_NP_NPU_PA_PlaybackElapsedTimeInMilliseconds                                    1
#define IAP2_NP_NPU_PA_PlaybackQueueIndex                                                   2
#define IAP2_NP_NPU_PA_PlaybackQueueCount                                                   3
#define IAP2_NP_NPU_PA_PlaybackQueueChapterIndex                                            4
#define IAP2_NP_NPU_PA_PlaybackShuffleMode                                                  5
#define IAP2_NP_NPU_PA_PlaybackRepeatMode                                                   6
#define IAP2_NP_NPU_PA_PlaybackAppName                                                      7
#define IAP2_NP_NPU_PA_PBMediaLibraryUniqueIdentifier                                       8
#define IAP2_NP_NPU_PA_PBAppleMusicRadioAd                                                  9
#define IAP2_NP_NPU_PA_PBAppleMusicRadioStationName                                         10
#define IAP2_NP_NPU_PA_PBAppleMusicRadioStationMediaPlaylistID                              11
#define IAP2_NP_NPU_PA_PlaybackSpeed                                                        12
#define IAP2_NP_NPU_PA_SetElapsedTimeAvailable                                              13
#define IAP2_NP_NPU_PA_PlaybackQueueListAvail                                               14
#define IAP2_NP_NPU_PA_PlaybackQueueListTransferID                                          15
#define IAP2_NP_NPU_PA_PlaybackAppBundleID                                                  16
#define IAP2_NP_NPU_PA_PlaybackQueueListContentTransfer                                     17

//**************************************************************************************
// IAP2 message, Now Playing, SetNowPlayingInformation

#define IAP2_NP_SNPI_ElapsedTime                                                            0
#define IAP2_NP_SNPI_PlaybackQueueIndex                                                     1

//**************************************************************************************
// IAP2 message, Out-of-Band Bluetooth Pairing R2
#define IAP2_R2_OOBBT_PAIRING                                                               0x00

#define IAP2_R2_OOBBTP_StartOOBBTPairing                                                    0xB0
#define IAP2_R2_OOBBTP_OOBBTPairingAccessoryInformation                                     0xB1
#define IAP2_R2_OOBBTP_OOBBTPairingLinkKeyInformation                                       0xB2
#define IAP2_R2_OOBBTP_OOBBTPairingCompletionInformation                                    0xB3
#define IAP2_R2_OOBBTP_StopOOBBTPairing                                                     0xB4

//**************************************************************************************
// IAP2 message, Out-of-Band Bluetooth Pairing, OOBBTPairingAccessoryInformation
#define IAP2_R2_OOBBTP_AI_BluetoothTransportComponentIdentifier                              0
#define IAP2_R2_OOBBTP_AI_DeviceClass                                                        1

//**************************************************************************************
// IAP2 message, Out-of-Band Bluetooth Pairing, OOBBTPairingLinkKeyInformation
#define IAP2_R2_OOBBTP_LI_LinkKey                                                             0
#define IAP2_R2_OOBBTP_LI_DeviceMACAddress                                                    1

//**************************************************************************************
// IAP2 message, Out-of-Band Bluetooth Pairing, OOBBTPairingCompletionInformation
#define IAP2_R2_OOBBTP_CI_ResultCode                                                          0

//**************************************************************************************
// IAP2 message, Out-of-Band Bluetooth Pairing R37

#define IAP2_OOBBT_PAIRING                                                                  0x0B

#define IAP2_OOBBTP_StartBluetoothPairing                                                   0x00
#define IAP2_OOBBTP_BluetoothPairingAccessoryInformation                                    0x01
#define IAP2_OOBBTP_BluetoothPairingStatus                                                  0x02
#define IAP2_OOBBTP_StopBluetoothPairing                                                    0x03

//**************************************************************************************
// IAP2 message, Out-of-Band Bluetooth Pairing, StartBluetoothPairing

#define IAP2_OOBBTP_StrBP_BluetoothTransportComponentIdentifier                              0
#define IAP2_OOBBTP_StrBP_DeviceMACAddress                                                   1

//**************************************************************************************
// IAP2 message, Out-of-Band Bluetooth Pairing, BluetoothPairingAccessoryInformation

#define IAP2_OOBBTP_BPAI_BluetoothTransportComponentIdentifier                               0
#define IAP2_OOBBTP_BPAI_PairingDataP192                                                     1
#define IAP2_OOBBTP_BPAI_PairingDataP256                                                     2

//**************************************************************************************
// IAP2 message, Out-of-Band Bluetooth Pairing, BluetoothPairingStatus

#define IAP2_OOBBTP_BPS_BluetoothTransportComponentIdentifier                                0
#define IAP2_OOBBTP_BPS_Success                                                              1
#define IAP2_OOBBTP_BPS_CancelReason                                                         2

//**************************************************************************************
// IAP2 message, Out-of-Band Bluetooth Pairing, StopBluetoothPairing

#define IAP2_OOBBTP_SBP_BluetoothTransportComponentIdentifier                               0
#define IAP2_OOBBTP_SBP_Success                                                             1
#define IAP2_OOBBTP_SBP_AlreadyPaired                                                       2
#define IAP2_OOBBTP_SBP_PairingCancel                                                       3

//**************************************************************************************
// IAP2 message, Power

#define IAP2_POWER                                                                          0xAE

#define IAP2_P_StartPowerUpdates                                                            0x00
#define IAP2_P_PowerUpdate                                                                  0x01
#define IAP2_P_StopPowerUpdates                                                             0x02
#define IAP2_P_PowerSourceUpdate                                                            0x03

//**************************************************************************************
// IAP2 message, Power, StartPowerUpdates

#define IAP2_P_SPU_MaximumCurrentDrawnFromAccessory                                         0
#define IAP2_P_SPU_DeviceBatteryWillChargeIfPowerIsPresent                                  1
#define IAP2_P_SPU_AccessoryPowerMode                                                       2
#define IAP2_P_SPU_IsExternalChargerConnected                                               4
#define IAP2_P_SPU_BatteryChargingState                                                     5
#define IAP2_P_SPU_BatteryChargeLevel                                                       6

//**************************************************************************************
// IAP2 message, Power, PowerUpdate

#define IAP2_P_PU_MaximumCurrentDrawnFromAccessory                                          0
#define IAP2_P_PU_DeviceBatteryWillChargeIfPowerIsPresent                                   1
#define IAP2_P_PU_AccessoryPowerMode                                                        2
#define IAP2_P_PU_IsExternalChargerConnected                                                4
#define IAP2_P_PU_BatteryChargingState                                                      5
#define IAP2_P_PU_BatteryChargeLevel                                                        6

//**************************************************************************************
// IAP2 message, Power, PowerSourceUpdate

#define IAP2_P_PSU_AvailableCurrentForDevice                                                0
#define IAP2_P_PSU_DeviceBatteryShouldChargeIfPowerIsPresent                                1

//**************************************************************************************
// IAP2 message, Route Guidance

#define IAP2_ROUTE_GUIDANCE                                                                 0x52

#define IAP2_RG_StartRouteGuidanceUpdates                                                   0x00
#define IAP2_RG_RouteGuidanceUpdate                                                         0x01
#define IAP2_RG_RouteGuidanceManeuverInformation                                            0x02
#define IAP2_RG_StopRouteGuidanceUpdates                                                    0x03

//**************************************************************************************
// IAP2 message, AppDiscovery

#define IAP2_AppDiscovery                                                                   0xAD

#define IAP2_APP_StartAppDiscoveryUpdates                                                   0x00
#define IAP2_APP_AppDiscoveryUpdates                                                        0x01

//**************************************************************************************
// IAP2 message, DestinationInformation

#define IAP2_DestinationInformation                                                         0x10

#define IAP2_APP_StartDestinationInformation                                                0xDA


//**************************************************************************************
// IAP2 message, Route Guidance, StartRouteGuidanceUpdate

#define IAP2_RG_StrRGU_RouteGuidanceDisplayComponentID                                      0
#define IAP2_RG_StrRGU_SourceName                                                           1
#define IAP2_RG_StrRGU_SourceSupportsRouteGuidance                                          2
#define IAP2_RG_StrRGU_SupportsExitInfo                                                     3

//**************************************************************************************
// IAP2 message, Route Guidance, RouteGuidanceUpdate

#define IAP2_RG_RGU_RouteGuidanceDisplayComponentID                                         0
#define IAP2_RG_RGU_RouteGuidanceState                                                      1
#define IAP2_RG_RGU_ManeuverState                                                           2
#define IAP2_RG_RGU_CurrentRoadName                                                         3
#define IAP2_RG_RGU_DestinationName                                                         4
#define IAP2_RG_RGU_EstimatedTimeOfArrival                                                  5
#define IAP2_RG_RGU_TimeRemainingToDestination                                              6
#define IAP2_RG_RGU_DestinationRemaining                                                    7
#define IAP2_RG_RGU_DestinationRemainingDisplayStr                                          8
#define IAP2_RG_RGU_DestinationRemainingDisplayUnits                                        9
#define IAP2_RG_RGU_DistanceToNextManeuver                                                  10
#define IAP2_RG_RGU_DistanceToNextManeuverDisplayStr                                        11
#define IAP2_RG_RGU_DistanceToNextManeuverDisplayUnits                                      12
#define IAP2_RG_RGU_RouteGuidanceManeuverCurrentList                                        13
#define IAP2_RG_RGU_RouteGuidanceManeuverCount                                              14
#define IAP2_RG_RGU_RouteGuidanceVisibleInApp                                               15

//**************************************************************************************
// IAP2 message, Route Guidance, RouteGuidanceManeuverUpdate

#define IAP2_RG_RGMU_RouteGuidanceDisplayComponentID                                        0
#define IAP2_RG_RGMU_Index                                                                  1
#define IAP2_RG_RGMU_ManeuverDescription                                                    2
#define IAP2_RG_RGMU_ManeuverType                                                           3
#define IAP2_RG_RGMU_AfterManeuverRoadName                                                  4
#define IAP2_RG_RGMU_DistanceBetweenManeuver                                                5
#define IAP2_RG_RGMU_DistanceBetweenManeuverDisplayStr                                      6
#define IAP2_RG_RGMU_DistanceBetweenManeuverDisplayUnits                                    7
#define IAP2_RG_RGMU_DrivingSide                                                            8
#define IAP2_RG_RGMU_JunctionType                                                           9
#define IAP2_RG_RGMU_JunctionElementAngle                                                   10
#define IAP2_RG_RGMU_JunctionElementExitAngle                                               11
#define IAP2_RG_RGMU_LinkedLaneGuidanceInformation                                          12
#define IAP2_RG_RGMU_ExitInfo                                                               13

//**************************************************************************************
// IAP2 message, Route Guidance, StopRouteGuidanceUpdate

#define IAP2_RG_StpRGU_RouteGuidanceDisplayComponentID                                      0

//**************************************************************************************
// IAP2 message, USB Device Mode Audio

#define IAP2_USB_DEVICE_MODE_AUDIO                                                          0xDA

#define IAP2_USBDMA_StartUSBDeviceModeAudio                                                 0x00
#define IAP2_USBDMA_USBDeviceModeAudioInformation                                           0x01
#define IAP2_USBDMA_StopUSBDeviceModeAudio                                                  0x02

//**************************************************************************************
// IAP2 message, USB Device Mode Audio, USBDeviceModeAudioInformation

#define IAP2_USBDMA_USBDMAI_SampleRate                                                      0

//**************************************************************************************
// IAP2 message, Vehicle Status

#define IAP2_VEHICLE_STATUS                                                                 0xA1

#define IAP2_VS_StartVehicleStatusUpdates                                                   0x00
#define IAP2_VS_VehicleStatusUpdate                                                         0x01
#define IAP2_VS_StopVehicleStatusUpdates                                                    0x02

//**************************************************************************************
// IAP2 message, Vehicle Status, StartVehicleStatusUpdates

#define IAP2_VS_SVSU_Range                                                                  3
#define IAP2_VS_SVSU_OutsideTemperature                                                     4
#define IAP2_VS_SVSU_RangeWarning                                                           6

//**************************************************************************************
// IAP2 message, Vehicle Status, VehicleStatusUpdate

#define IAP2_VS_VSU_Range                                                                   3
#define IAP2_VS_VSU_OutsideTemperature                                                      4
#define IAP2_VS_VSU_RangeWarning                                                            6

//**************************************************************************************
// IAP2 message, VoiceOver

#define IAP2_VOICE_OVER                                                                     0x56

#define IAP2_VO_StartVoiceOver                                                              0x12
#define IAP2_VO_StopVoiceOver                                                               0x13
#define IAP2_VO_RequestVoiceOverMoveCursor                                                  0x01
#define IAP2_VO_RequestVoiceOverActivateCursor                                              0x02
#define IAP2_VO_RequestVoiceOverScrollPage                                                  0x03
#define IAP2_VO_RequestVoiceOverSpeakText                                                   0x06
#define IAP2_VO_RequestVoiceOverPauseText                                                   0x08
#define IAP2_VO_RequestVoiceOverResumeText                                                  0x09
#define IAP2_VO_StartVoiceOverUpdates                                                       0x0B
#define IAP2_VO_VoiceOverUpdate                                                             0x0C
#define IAP2_VO_StopVoiceOverUpdates                                                        0x0D
#define IAP2_VO_RequestVoiceOverConfiguration                                               0x0E
#define IAP2_VO_StartVoiceOverCursorUpdates                                                 0x0F
#define IAP2_VO_VoiceOverCursorUpdate                                                       0x10
#define IAP2_VO_StopVoiceOverCursorUpdates                                                  0x11

//**************************************************************************************
// IAP2 message, VoiceOver, RequestVoiceOverMoveCursor

#define IAP2_VO_RVOMC_CursorDirection                                                       0

//**************************************************************************************
// IAP2 message, VoiceOver, RequestVoiceOverScrollPage

#define IAP2_VO_RVOSP_ScrollDirection                                                       0

//**************************************************************************************
// IAP2 message, VoiceOver, RequestVoiceOverSpeakText

#define IAP2_VO_RVOST_TextToSpeak                                                           0

//**************************************************************************************
// IAP2 message, VoiceOver, StartVoiceOverUpdates

#define IAP2_VO_SVOU_SpeakingVolume                                                         0
#define IAP2_VO_SVOU_SpeakingRate                                                           1
#define IAP2_VO_SVOU_Enabled                                                                2

//**************************************************************************************
// IAP2 message, VoiceOver, VoiceOverUpdate

#define IAP2_VO_VOU_SpeakingVolume                                                          0
#define IAP2_VO_VOU_SpeakingRate                                                            1
#define IAP2_VO_VOU_Enabled                                                                 2

//**************************************************************************************
// IAP2 message, VoiceOver, RequestVoiceOverConfiguration

#define IAP2_VO_RVOC_SpeakingVolume                                                         0
#define IAP2_VO_RVOC_SpeakingRate                                                           1

//**************************************************************************************
// IAP2 message, VoiceOver, StartVoiceOverCursorUpdates

#define IAP2_VO_SVOCU_Label                                                                 0
#define IAP2_VO_SVOCU_Value                                                                 1
#define IAP2_VO_SVOCU_Hint                                                                  2
#define IAP2_VO_SVOCU_Traits                                                                3

//**************************************************************************************
// IAP2 message, VoiceOver, VoiceOverCursorUpdate

#define IAP2_VO_VOCU_Label                                                                  0
#define IAP2_VO_VOCU_Value                                                                  1
#define IAP2_VO_VOCU_Hint                                                                   2
#define IAP2_VO_VOCU_Traits                                                                 3

//**************************************************************************************
// IAP2 message, Wi-Fi Information Sharing

#define IAP2_WIFI_INFORMATION_SHARING                                                       0x57

#define IAP2_WIFIIS_RequestWiFiInformation                                                  0x00
#define IAP2_WIFIIS_WiFiInformation                                                         0x01
#define IAP2_WIFIIS_RequestAccessoryWiFiConfigurationInformation                            0x02
#define IAP2_WIFIIS_AccessoryWiFiConfigurationInformation                                   0x03

//**************************************************************************************
// IAP2 message, Wi-Fi Information Sharing, WiFiInformation

#define IAP2_WIFIIS_WIFII_RequestStatus                                                     0
#define IAP2_WIFIIS_WIFII_SecurityType                                                      1
#define IAP2_WIFIIS_WIFII_WiFiSSID                                                          2
#define IAP2_WIFIIS_WIFII_WiFiPassphrase                                                    3

//**************************************************************************************
// IAP2 message, Wi-Fi Information Sharing, WiFiInformation, RequestStatus

#define IAP2_WIFIIS_WIFII_ST_WEP                                                     0
#define IAP2_WIFIIS_WIFII_ST_WPA                                                     1
#define IAP2_WIFIIS_WIFII_ST_WPA2                                                    2
#define IAP2_WIFIIS_WIFII_ST_MixedWPAWPA2                                            3

//**************************************************************************************
// IAP2 message, Wi-Fi Information Sharing, WiFiInformation, RequestStatus

#define IAP2_WIFIIS_WIFII_RS_Success                                                     0
#define IAP2_WIFIIS_WIFII_RS_UserDeclined                                                1
#define IAP2_WIFIIS_WIFII_RS_Unavailable                                                 2

//**************************************************************************************
// IAP2 message, Wi-Fi Information Sharing, AccessoryWiFiConfigurationInformation

#define IAP2_WIFIIS_AWIFICI_WiFiSSID                                                        1
#define IAP2_WIFIIS_AWIFICI_Passphrase                                                      2
#define IAP2_WIFIIS_AWIFICI_SecurityType                                                    3
#define IAP2_WIFIIS_AWIFICI_Channel                                                         4

//**************************************************************************************
// IAP2 message, Wi-Fi Information Sharing, AccessoryWiFiConfigurationInformation,SecurityType

#define IAP2_WIFIIS_AWIFICI_ST_None                                                        0
#define IAP2_WIFIIS_AWIFICI_ST_WEP                                                         1
#define IAP2_WIFIIS_AWIFICI_ST_WPA2_WPA3                                                   2

//**************************************************************************************
// Section: iAP2 Messages, FileTransfer

#define IAP2_FILE_TRANSFER_SETUP_DATAGRAM                                                   0x04
#define IAP2_FILE_TRANSFER_START                                                            0x01
#define IAP2_FILE_TRANSFER_FIRST_DATA                                                       0x80
#define IAP2_FILE_TRANSFER_FIRST_AND_ONLY_DATA                                              0xC0
#define IAP2_FILE_TRANSFER_DATA                                                             0x00
#define IAP2_FILE_TRANSFER_LAST_DATA                                                        0x40
#define IAP2_FILE_TRANSFER_CANCEL                                                           0x02
#define IAP2_FILE_TRANSFER_PAUSE                                                            0x03
#define IAP2_FILE_TRANSFER_SUCCESS                                                          0x05
#define IAP2_FILE_TRANSFER_FAILURE                                                          0x06

//**************************************************************************************
// Section: iAP2 Messages, SampleRate

#define USB_DEVICE_AUDIO_SAMPLE_RATE_8000                                                   8000
#define USB_DEVICE_AUDIO_SAMPLE_RATE_11025                                                  11025
#define USB_DEVICE_AUDIO_SAMPLE_RATE_12000                                                  12000
#define USB_DEVICE_AUDIO_SAMPLE_RATE_16000                                                  16000
#define USB_DEVICE_AUDIO_SAMPLE_RATE_22050                                                  22050
#define USB_DEVICE_AUDIO_SAMPLE_RATE_24000                                                  24000
#define USB_DEVICE_AUDIO_SAMPLE_RATE_32000                                                  32000
#define USB_DEVICE_AUDIO_SAMPLE_RATE_44100                                                  44100
#define USB_DEVICE_AUDIO_SAMPLE_RATE_48000                                                  48000

//**************************************************************************************
// Section: iAP2 Messages, CarPlayConnection
#define IAP2_CARPLAY_CONNECTION                                 0x43

#define IAP2_CPC_CarPlayAvailability                            0x00
#define IAP2_CPC_CarPlayStartSession                            0x01

//**************************************************************************************
// Section: iAP2 Messages, CarPlayConnection, CarPlayAvailability
#define IAP2_CPC_CPA_WiredAttributes                            0
#define IAP2_CPC_CPA_WirelessAttributes                         1

// Section: iAP2 Messages, CarPlayConnection, CarPlayAvailability,WiredAttributes
#define IAP2_CPC_CPA_W_Available                                0
#define IAP2_CPC_CPA_W_USBTransportIdentifier                   1

// Section: iAP2 Messages, CarPlayConnection, CarPlayAvailability,WirelessAttributes
#define IAP2_CPC_CPA_WL_Available                               0
#define IAP2_CPC_CPA_WL_BluetoothTransportIdentifier            1

//**************************************************************************************
// Section: iAP2 Messages, CarPlayConnection, CarPlayStartSession
#define IAP2_CPC_CPSS_WiredAttributes                           0
#define IAP2_CPC_CPSS_WirelessAttributes                        1
#define IAP2_CPC_CPSS_Port                                      2
#define IAP2_CPC_CPSS_DeviceIdentifier                          3
#define IAP2_CPC_CPSS_PublicKey                                 4
#define IAP2_CPC_CPSS_SourceVersion                             5

// Section: iAP2 Messages, CarPlayConnection, CarPlayStartSession,WiredAttributes
#define IAP2_CPC_CPSS_W_IPAddress                               0

// Section: iAP2 Messages, CarPlayConnection, CarPlayStartSession,WirelessAttributes
#define IAP2_CPC_CPSS_WL_WiFiSSID                               0
#define IAP2_CPC_CPSS_WL_Passphrase                             1
#define IAP2_CPC_CPSS_WL_Channel                                2
#define IAP2_CPC_CPSS_WL_IPAddress                              3
#define IAP2_CPC_CPSS_WL_SecurityType                           4

// Section: iAP2 Messages, CarPlayConnection

#define IAP2_CARPLAY_CONNECTION                                 0x43

#define IAP2_CPC_CarPlayAvailability                            0x00
#define IAP2_CPC_CarPlayStartSession                            0x01


// -----------------------------------------------------------------------------
// Section: iAP2 Messages, CarPlayConnection, CarPlayAvailability

#define IAP2_CPC_CPA_WiredAttributes                            0
#define IAP2_CPC_CPA_WirelessAttributes                         1
//WiredAttributes
#define IAP2_CPC_CPA_W_Available                                0
#define IAP2_CPC_CPA_W_USBTransportIdentifier                   1
//WirelessAttributes
#define IAP2_CPC_CPA_WL_Available                               0
#define IAP2_CPC_CPA_WL_BluetoothTransportIdentifier            1

// -----------------------------------------------------------------------------
// Section: iAP2 Messages, CarPlayConnection, CarPlayStartSession

#define IAP2_CPC_CPSS_WiredAttributes                           0
#define IAP2_CPC_CPSS_WirelessAttributes                        1
#define IAP2_CPC_CPSS_Port                                      2
#define IAP2_CPC_CPSS_DeviceIdentifier                          3
#define IAP2_CPC_CPSS_PublicKey                                 4
#define IAP2_CPC_CPSS_SourceVersion                             5

//WiredAttributes
#define IAP2_CPC_CPSS_W_IPAddress                               0

//WirelessAttributes
#define IAP2_CPC_CPSS_WL_WiFiSSID                               0
#define IAP2_CPC_CPSS_WL_Passphrase                             1
#define IAP2_CPC_CPSS_WL_Channel                                2
#define IAP2_CPC_CPSS_WL_IPAddress                              3
#define IAP2_CPC_CPSS_WL_SecurityType                           4

//USB SharkCarPlay
#define IAP2_SHARK_CARPLAY_ENABLE                              1


/**************************************************************************************
 * Section: Data Struct
 **************************************************************************************/
#ifdef __cplusplus
extern "C"{
#endif

/**
 * Big Endian Data
 * The Apple device sends data in big endian format. This structure is used to map that information.
 */
typedef union {
    uint16  valueFlipped;
    struct  __attribute__((packed)) {
        uint8   MSB;
        uint8   LSB;
    } bytes;
} IAP2_BIG_ENDIAN_16BITS;

/**
 * Link Packet Header
 * This is the structure of the Control Byte in the iAP2 Link Packet.
 * The application layer does not need to utilize this information.
 */
typedef union {
    uint8   value;
    struct {
        uint8                       : 1;
        uint8                       : 1;
        uint8                       : 1;
        uint8   SLP                 : 1;
        uint8   RST                 : 1;
        uint8   EAK                 : 1;
        uint8   ACK                 : 1;
        uint8   SYN                 : 1;
    };
} IAP2_CONTROL_BYTE;

/**
 * Link Packet Header
 * This is the structure of the link packet header. The application layer may need
 * to access the sessionID member of this structure. All other fields are handled by the library.
 */
typedef struct __attribute__((packed)) {
    uint8                   startOfPacketMSB;
    uint8                   startOfPacketLSB;
    IAP2_BIG_ENDIAN_16BITS  length;
    IAP2_CONTROL_BYTE       controlByte;
    uint8                   sequenceNumber;
    uint8                   ackNumber;
    uint8                   sessionID;
    uint8                   checksum;
} IAP2_LINK_PACKET_HEADER;

/**
 * Link Packet - Input
 * This is the structure of a link packet that is received from the Apple device.
 * There is is a separate structure defined for a link packet that is sent to the
 * Apple device, to allow for different receive and transmit data lengths.
 * Note that the payload field includes the payload checksum.
 */
typedef union {
    uint8                       bytes[ IAP2_MAXIMUM_PACKET_LENGTH_IN ];
    struct __attribute__((packed)) {
        IAP2_LINK_PACKET_HEADER header;
        uint8                   payload [ IAP2_MAXIMUM_PACKET_LENGTH_IN - sizeof(IAP2_LINK_PACKET_HEADER) ];
    };
} IAP2_LINK_PACKET_IN;

/**
 * Link Packet - Output
 * This is the structure of a link packet that is sent to the Apple device.
 * There is is a separate structure defined for a link packet that is received from the
 * Apple device, to allow for different receive and transmit data lengths.
 * Note that the payload field includes the payload checksum.
 */
typedef union {
    uint8                       bytes[ IAP2_MAXIMUM_PACKET_LENGTH_OUT ];
    struct __attribute__((packed)) {
        IAP2_LINK_PACKET_HEADER header;
        uint8                   payload [ IAP2_MAXIMUM_PACKET_LENGTH_OUT - sizeof(IAP2_LINK_PACKET_HEADER) ];
    };
} IAP2_LINK_PACKET_OUT;

/**
 * Apple Device Communication Status
 * This structure indicates the current status of Apple device interaction.
 * Each bit indicates some sort of communication is in progress with the Apple device.
 * If the entire value is 0, communication with the Apple device is currently not in progress.
 */
typedef union {
    uint8   value;
    struct {
        uint8   identifying                 : 1;
        uint8   authenticating              : 1;
        uint8   receivingCommand            : 1;
        uint8   commandInBuffer             : 1;
        uint8   transmittingCommand         : 1;
        uint8   commandReadyToTransmit      : 1;
    };
} IAP2_COMMUNICATION_STATUS;

/**************************************************************************************
 * Section: General Macros
 **************************************************************************************/

#define HIGH_BYTE(x)                        (((x) >> 8) & 0xFF)
#define LOW_BYTE(x)                         ((x) & 0xFF)

#define IAP2_BIG_ENDIAN(x,y)                ( (uint16)( ((uint16)x << 8) + y ) )
#define IAP2_PAYLOAD_BYTE( x )              ( ((IAP2_LINK_PACKET_IN *)data)->payload[ x ] )
#define IAP2_BIG_ENDIAN_PAYLOAD(x)          ( (uint16)( ((uint16)IAP2_PAYLOAD_BYTE(x) << 8) + IAP2_PAYLOAD_BYTE(x + 1) ) )
#define IAP2_BIG_ENDIAN_VALUE(x)            ( (uint16)( ((uint16)(data[x]) << 8) + (data[x + 1]) ) )
#define IAP2_BIG_ENDIAN_VALUE_HID(x)            ( (uint16)( ((uint16)(hidData[x]) << 8) + (hidData[x + 1]) ) )
#define IAP2_BIG_ENDIAN_SWITCH(x)           ( (uint16)(x & 0xFF) << 8 ) + ( (x >> 8) & 0xFF )

/**************************************************************************************
 * Section: Type Definition
 **************************************************************************************/

class IAP2AuthenticationState {
public:
    enum { NONE, SUCCEEDED, FAILED };
};

class IAP2IdentificationState {
public:
    enum { NONE, ACCEPTED, REJECTED };
};

class IAP2AppLaunchMethod {
public:
    enum { WITH_ALERT, WITHOUT_ALERT };
};

class IAP2CallStatus {
public:
    enum { DISCONNECTED, SENDING, RINGING, CONNECTING, ACTIVE, HELD, DISCONNECTING };
};

class IAP2CallDirection {
public:
    enum { UNKNOWN, INCOMING, OUTGOING };
};

class IAP2CallService {
public:
    enum { UNKNOWN, TELEPHONY, FACETIME_AUDIO, FACETIME_VIDEO };
};

class IAP2CallDisconnectReason {
public:
    enum { NO_REASON, CALL_ENDED = NO_REASON, CALL_DECLINED, CALL_FAILED };
};

class IAP2CallStatusLagacy {
public:
    enum { DISCONNECTED, ACTIVE, HELD, RINGING, SENDING = RINGING };
};

class IAP2CallDirectionLegacy {
public:
    enum { INCOMING, OUTGOING, UNKNOWN };
};

class IAP2CommSignalStrength {
public:
    enum { BARS_0, BAR_1, BARS_2, BARS_3, BARS_4, BARS_5 };
};

class IAP2CommRegistrationStatus {
public:
    enum { UNKNOWN, NOT_REGISTERED, SEARCHING, DENIED, REGISTERED_HOME, REGISTERED_ROAMING, EMERGENCY_CALLS_ONLY };
};

class IAP2InitiateCallType {
public:
    enum { DESTINATION, VOICEMAIL, REDIAL };
};

class IAP2InitiateCallService {
public:
    enum { TELEPHONY = 1, FACETIME_AUDIO, FACETIME_VIDEO };
};

class IAP2CallAcceptAction {
public:
    enum { ACCEPT, HOLD_AND_ACCEPT = ACCEPT, END_AND_ACCEPT };
};

class IAP2CallEndAction {
public:
    enum { END, DECLINED = END, END_ALL };
};

class IAP2DTMFTone {
public:
    enum { NUMBER_0, NUMBER_1, NUMBER_2, NUMBER_3, NUMBER_4, NUMBER_5, NUMBER_6, NUMBER_7, NUMBER_8, NUMBER_9, STAR, POUND };
};

class IAP2ListService {
public:
    enum { UNKNOWN, TELEPHONY, FACETIME_AUDIO, FACETIME_VIDEO };
};

class IAP2RecentListType {
public:
    enum { UNKNOWN, IMCOMING, OUTGOING, MISSED };
};

class IAP2WirelessCarPlayStatus {
public:
    enum { UNAVAILABLE, AVAILABLE };
};

class IAP2EAPSessionStatus {
public:
    enum { OK, CLOSED };
};

class IAP2PowerMode {
public:
    enum { RESERVED, LOW, INTERMITTENT_HIGH };
};

class IAP2BatteryChargingState {
public:
    enum { DISABLED, CHARGING, CHARGED };
};

class IAP2RouteGuidanceState {
public:
    enum { NO_ROUTE_SET, ROUTE_SET, ARRIVED, LOADING, LOCATING, REROUTING, PROCEED_TO_ROUTE };
};

class IAP2ManeuverState {
public:
    enum { CONTINUE, INITIAL, PREPARE, EXECUTE };
};

class IAP2DistanceDisplayUnits {
public:
    enum { KM, MILES, M, YARDS, FT };
};

class IAP2DrivingState {
public:
    enum { RIGHT, LEFT };
};

class IAP2VoiceOverCursorDirection {
public:
    enum { NEXT, PREVIOUS, ESCAPE };
};

class IAP2VoiceOverScrollDirection {
public:
    enum { LEFT, RIGHT, UP, DOWN };
};

class IAP2MediaCommand {
public:
    enum {
        UP          = 0x00,
        PLAY_PAYUSE = 0x01,
        NEXT        = 0x02,
        PREVIOUS    = 0x04,
        SHUFFLE     = 0x08,
        REPEAT      = 0x10,
        PLAY        = 0x20,
        PAUSE       = 0x40,
    };
};

class IAP2FileTransferType {
public:
    enum { ARTWORK, PLAYLIST, PLAYING_LIST };
};

class IAP2MediaLibraryType {
public:
    enum { LOCAL_DEVICE, MUSIC_RADIO = 2 };
};

class IAP2MediaType {
public:
    enum { MUSIC, PODCAST, AUDIOBOOK, ITUNES_U };
};

class IAP2MediaCollectionType {
public:
    enum { PLAYLIST, ARTIST, ALBUM, ALBUM_ARTIST, GENRE, COMPOSER };
};

class IAP2HID {
public:
    enum { VEHICLE_PID = 0x00FF, MEDIA_VID = 0x0001 };
};

/**
 * 多媒体HID描述
 */
const uint8 mediaDescriptor[] = {
    0x05, 0x0C,     // USAGE_PAGE (Consumer Devices)
    0x09, 0x01,     // USAGE (Consumer Control)
    0xA1, 0x01,     // COLLECTION (Application)
    0x15, 0x00,     // LOGICAL_MINIMUM (0)
    0x25, 0x01,     // LOGICAL_MAXIMUM (1)
    0x75, 0x01,     // REPORT_SIZE (1)
    0x95, 0x07,     // REPORT_COUNT (7)
    0x09, 0xCD,     // USAGE (Play/Pause)
    0x09, 0xB5,     // USAGE (Scan Next Track)
    0x09, 0xB6,     // USAGE (Scan Previous Track)
    0x09, 0xB9,     // USAGE (Shuffle)
    0x09, 0xBC,     // USAGE (Repeat)
    0x09, 0xB0,     // USAGE (Play)
    0x09, 0xB1,     // USAGE (Pause)
    0x81, 0x02,     // INPUT (Data,Var,Abs)
    0x75, 0x01,     // REPORT_SIZE (1)
    0x95, 0x01,     // REPORT_COUNT (1)
    0x81, 0x03,     // INPUT (Data,Var,Abs)
    0xC0            // END_COLLECTION
};


/**
 * IAP2 EA协议
 */
class IAP2EAPStatus {
public:
    IAP2EAPStatus() {
        id          = 0;
        sessionID   = 0;
        status      = IAP2EAPSessionStatus::CLOSED;
    }
    ~IAP2EAPStatus() {}

    uint8                   id;
    uint16                  sessionID;
    std::string             protocol;
    int                     status;
};

/**
 * IAP2 位置信息类型
 */
typedef union {
    uint8   value;
    struct {
        uint8										: 1;
        uint8 	GlobalPositioningSystemFixData  	: 1;	//GPGGA
        uint8   RecomendedSpecificGPSTransitData   	: 1;	//GPRMC
        uint8   GPSSatellitesInView  				: 1;	//GPGSV
        uint8   VehicleSpeedData					: 1;	//PASCD
        uint8   VehicleGyroData						: 1;	//PAGCD
        uint8   VehicleAccelerometerData			: 1;	//PAACD
        uint8	VehicleHeadingData					: 1;	//GPHDT
    };
} IAP2LocationType;

/**
 * IAP2 CallStatusInformation
 */
class IAP2CallStatusInfo {
public:
    IAP2CallStatusInfo() {
        status              = IAP2CallStatus::DISCONNECTED;
        direction           = IAP2CallDirection::UNKNOWN;
    }
    ~IAP2CallStatusInfo() {}

    std::string             remoteID;
    std::string             displayName;
    int                     status;
    int                     direction;
    std::string             callUUID;
};

/**
 * IAP2 设备信息
 */
typedef struct
{
    std::string    USBTransportIdentifier;
    std::string    BluetoothTransportIdentifier;
 } DeviceTransportNotification;

/**
 * IAP2 当前播放状态
 */
class IAP2NowPlaying{
public:
    IAP2NowPlaying() {
        id                              = 0;
        duration                        = 0;
        albumTrackNumber                = 0;
        albumTrackCount                 = 0;
        albumDiscNumber                 = 0;
        albumDiscCount                  = 0;
        isLikeSupported                 = false;
        isBanSupported                  = false;
        isLiked                         = false;
        isBanned                        = false;
        chapterCount                    = 0;
        chapterIndex                    = 0;
        state                           = IPODPlaybackState::STOPPED;
        position                        = 0;
        index                           = 0;
        count                           = 0;
        shuffleMode                     = IPODShuffleMode::OFF;
        repeatMode                      = IPODRepeatMode::OFF;
        iTunesRadioAd                   = false;
        iTunesRadioStationPlaylistID    = 0;
        speed                           = 0;
        setPositionAvailable            = false;
        queueListAvailable              = false;
        artworkInited                   = false;
        inited                          = false;
    }
    ~IAP2NowPlaying() {}

    uint64              id;
    uint32              duration;
    std::string         title;
    std::string         album;
    std::string         artist;
    std::string         genre;
    std::string         composer;
    uint16              albumTrackNumber;
    uint16              albumTrackCount;
    uint16              albumDiscNumber;
    uint16              albumDiscCount;
    bool                isLikeSupported;
    bool                isBanSupported;
    bool                isLiked;
    bool                isBanned;
    uint16              chapterCount;
    uint32              chapterIndex;
    int                 state;
    uint32              position;
    uint32              index;
    uint32              count;
    int                 shuffleMode;
    int                 repeatMode;
    std::string         appName;
    std::string         libraryID;
    bool                iTunesRadioAd;
    std::string         iTunesRadioStationName;
    uint64              iTunesRadioStationPlaylistID;
    uint16              speed;
    bool                setPositionAvailable;
    bool                queueListAvailable;
    std::string         appBundleID;
    bool                artworkInited;
    std::string         artworkPath;
    bool                inited;
};

/**
 * IAP2 文件传输属性
 */
class IAP2FileTransfer {
public:
    IAP2FileTransfer() {
        id = 0;
        type = IAP2FileTransferType::ARTWORK;
        total = 0;
        received = 0;
        data = NULL;
        libraryType = IAP2MediaLibraryType::LOCAL_DEVICE;
        playlistid = 0;
    }
    ~IAP2FileTransfer() {}

    uint8                   id;             // id
    int                     type;           // 类型
    uint64                  total;          // 总数据大小
    uint64                  received;       // 已接收数据大小
    uint8                   *data;          // 数据
    int                     libraryType;    // 媒体库类型
    uint64                  playlistid;     // 播放列表时有效
};

/**
 * IAP2 正在播放列表文件传输属性
 */
class IAP2FilePlayingList {
public:
    IAP2FilePlayingList() {
        total = 0;
        libraryType = IAP2MediaLibraryType::LOCAL_DEVICE;
        items.clear();
        playlistid = 0;
    }
    ~IAP2FilePlayingList() {}

    uint32                  total;          // 总数据大小
    std::list<uint64>       items;          // 歌曲item
    int                     libraryType;    // 媒体库类型
    uint64                  playlistid;     // 播放列表时有效
};

/**
 * IAP2 多媒体数据库
 */
class IAP2MediaLibrary {
public:
    IAP2MediaLibrary() {
        type = IAP2MediaLibraryType::LOCAL_DEVICE;
        progress = 0;
        hideRemoteItems = false;
        allSongsCapable = true;
    }
    ~IAP2MediaLibrary() {}

    std::string             id;
    std::string             name;
    int                     type;
    std::string             revision;
    uint8                   progress;
    bool                    hideRemoteItems;
    bool                    allSongsCapable;
};

/**
 * IAP2 歌曲属性
 */
class IAP2MediaItem {
public:
    IAP2MediaItem() {
        id = 0;
        type = IAP2MediaType::MUSIC;
        rating = 0;
        duration = 0;
        albumID = 0;
        albumTrackNumber = 0;
        albumTrackCount = 0;
        albumDiscNumber = 0;
        albumDiscCount = 0;
        artistID = 0;
        albumArtistID = 0;
        genreID = 0;
        composerID = 0;
        partOfCompilation = false;
        likeSupported = false;
        banSupported = false;
        liked = false;
        banned = false;
        residentOnDevice = false;
        chapterCount = false;
    }
    ~IAP2MediaItem() {}

    uint64          id;
    std::string     title;
    int             type;
    uint8           rating;
    uint32          duration;
    uint64          albumID;
    std::string     album;
    uint16          albumTrackNumber;
    uint16          albumTrackCount;
    uint16          albumDiscNumber;
    uint16          albumDiscCount;
    uint64          artistID;
    std::string     artist;
    uint64          albumArtistID;
    std::string     albumArtist;
    uint64          genreID;
    std::string     genre;
    uint64          composerID;
    std::string     composer;
    bool            partOfCompilation;
    bool            likeSupported;
    bool            banSupported;
    bool            liked;
    bool            banned;
    bool            residentOnDevice;
    uint16          chapterCount;
};

/**
 * IAP2 播放列表属性
 */
class IAP2MediaPlaylist {
public:
    IAP2MediaPlaylist() {
        id = 0;
        parentID = 0;
        geniusMix = false;
        folder = false;
        fileTransferID = 0;
        iTunesRadioStation = false;
    }
    ~IAP2MediaPlaylist() {}

    uint64          id;
    std::string     name;
    uint64          parentID;
    bool            geniusMix;
    bool            folder;
    uint8           fileTransferID;
    bool            iTunesRadioStation;
};

/**
 * IAP2 列表属性
 */
class IAP2MediaList {
public:
    IAP2MediaList() {
        category = IPODCategoryType::ALL;
        count = 0;
        parentID = 0;
    }
    ~IAP2MediaList() {}

    int                                 category;
    uint32                              count;
    std::map<uint32, IPODMusicSource>   items;
    uint64                              parentID;
};

#ifdef __cplusplus
}
#endif
#endif /* IAP2DEF_H_ */
